﻿using System;
namespace SqlSugar
{
    public class DbColumnInfo
    {
        public string TableName { get; set; }
        public int TableId { get; set; }
        public string DbColumnName { get; set; }
        public string PropertyName { get; set; }
        public string DataType { get; set; }
        public Type PropertyType { get; set; }
        public int Length { get; set; }
        public string ColumnDescription { get; set; }
        public string DefaultValue { get; set; }
        public bool IsNullable { get; set; }
        public bool IsIdentity { get; set; }
        public bool IsPrimarykey { get; set; }
        public object Value { get; set; }
        public int DecimalDigits { get; set; }
        public int Scale { get; set; }
        public bool IsArray { get; set; }
        internal bool IsJson { get; set; }

        public bool IsChange(DbColumnInfo column)
        {

            bool isDataTypeNoChange = this.DataType == column.DataType || this.DataType == "bigint" && column.DataType == "int" || this.DataType == "nvarchar" && column.DataType == "varchar";

            bool isNullable = this.IsNullable == column.IsNullable;
            bool IsPrimarykey = this.IsPrimarykey == column.IsPrimarykey;
            bool IsIdentity = this.IsIdentity == column.IsIdentity;
            bool isLength = this.Length == column.Length;
            bool isDecimalDigits = this.DecimalDigits == column.DecimalDigits;


            if (isDataTypeNoChange & isNullable & IsPrimarykey & IsIdentity & isLength & isDecimalDigits)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}
